<!DOCTYPE html>
<html>
<head><meta name="generator" content="Hexo 3.9.0">
  <meta charset="utf-8">
  

  
  <title>赌博游戏 | mmmmmars的demo例子</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="description" content="玩家摇两颗色子 如果第一次摇出 7 点或 11 点 玩家胜如果摇出 2 点 3 点 12 点 庄家胜 其他情况游戏继续玩家再次要色子 如果摇出 7 点 庄家胜如果摇出第一次摇的点数 玩家胜否则游戏继续 玩家继续摇色子玩家进入游戏时有 1000 元的赌注 全部输光游戏结束。 1234567891011121314151617181920212223242526272829303132333435fr">
<meta name="keywords" content="Python">
<meta property="og:type" content="article">
<meta property="og:title" content="赌博游戏">
<meta property="og:url" content="http://zhaobin.statusplus.top/2019/09/04/craps/index.html">
<meta property="og:site_name" content="mmmmmars的demo例子">
<meta property="og:description" content="玩家摇两颗色子 如果第一次摇出 7 点或 11 点 玩家胜如果摇出 2 点 3 点 12 点 庄家胜 其他情况游戏继续玩家再次要色子 如果摇出 7 点 庄家胜如果摇出第一次摇的点数 玩家胜否则游戏继续 玩家继续摇色子玩家进入游戏时有 1000 元的赌注 全部输光游戏结束。 1234567891011121314151617181920212223242526272829303132333435fr">
<meta property="og:locale" content="zh-CN">
<meta property="og:updated_time" content="2019-09-05T02:25:42.060Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="赌博游戏">
<meta name="twitter:description" content="玩家摇两颗色子 如果第一次摇出 7 点或 11 点 玩家胜如果摇出 2 点 3 点 12 点 庄家胜 其他情况游戏继续玩家再次要色子 如果摇出 7 点 庄家胜如果摇出第一次摇的点数 玩家胜否则游戏继续 玩家继续摇色子玩家进入游戏时有 1000 元的赌注 全部输光游戏结束。 1234567891011121314151617181920212223242526272829303132333435fr">
  
    <link rel="alternate" href="/atom.xml" title="mmmmmars的demo例子" type="application/atom+xml">
  
  
    <link rel="icon" href="/favicon.png">
  
  
    <link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
  
  <link rel="stylesheet" href="/css/style.css">
</head>
</html>
<body>
  <div id="container">
    <div id="wrap">
      <header id="header">
  <div id="banner"></div>
  <div id="header-outer" class="outer">
    <div id="header-title" class="inner">
      <h1 id="logo-wrap">
        <a href="/" id="logo">mmmmmars的demo例子</a>
      </h1>
      
        <h2 id="subtitle-wrap">
          <a href="/" id="subtitle">总结写过的一些小demo</a>
        </h2>
      
    </div>
    <div id="header-inner" class="inner">
      <nav id="main-nav">
        <a id="main-nav-toggle" class="nav-icon"></a>
        
          <a class="main-nav-link" href="/">Home</a>
        
          <a class="main-nav-link" href="/archives">Archives</a>
        
      </nav>
      <nav id="sub-nav">
        
          <a id="nav-rss-link" class="nav-icon" href="/atom.xml" title="RSS Feed"></a>
        
        <a id="nav-search-btn" class="nav-icon" title="搜索"></a>
      </nav>
      <div id="search-form-wrap">
        <form action="//google.com/search" method="get" accept-charset="UTF-8" class="search-form"><input type="search" name="q" class="search-form-input" placeholder="Search"><button type="submit" class="search-form-submit">&#xF002;</button><input type="hidden" name="sitesearch" value="http://zhaobin.statusplus.top"></form>
      </div>
    </div>
  </div>
</header>
      <div class="outer">
        <section id="main"><article id="post-craps" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2019/09/04/craps/" class="article-date">
  <time datetime="2019-09-04T08:28:30.000Z" itemprop="datePublished">2019-09-04</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 class="article-title" itemprop="name">
      赌博游戏
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <p>玩家摇两颗色子 如果第一次摇出 7 点或 11 点 玩家胜<br>如果摇出 2 点 3 点 12 点 庄家胜 其他情况游戏继续<br>玩家再次要色子 如果摇出 7 点 庄家胜<br>如果摇出第一次摇的点数 玩家胜<br>否则游戏继续 玩家继续摇色子<br>玩家进入游戏时有 1000 元的赌注 全部输光游戏结束。</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">from</span> random <span class="keyword">import</span> randint</span><br><span class="line"></span><br><span class="line">money = <span class="number">1000</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">while</span> money &gt; <span class="number">0</span>:</span><br><span class="line">    print(<span class="string">'您的总资产为:'</span>, money)</span><br><span class="line">    needs_go_on = <span class="literal">False</span></span><br><span class="line">    <span class="keyword">while</span> <span class="literal">True</span>:</span><br><span class="line">        debt = int(input(<span class="string">'请下注:'</span>))</span><br><span class="line">        <span class="keyword">if</span>(<span class="number">0</span> &lt; debt &lt;= money):</span><br><span class="line">            <span class="keyword">break</span></span><br><span class="line">    first = randint(<span class="number">1</span>, <span class="number">6</span>)+randint(<span class="number">1</span>, <span class="number">6</span>)</span><br><span class="line">    print(<span class="string">'玩家摇出%d点'</span> % first)</span><br><span class="line">    <span class="keyword">if</span> first == <span class="number">7</span> <span class="keyword">or</span> first == <span class="number">11</span>:</span><br><span class="line">        print(<span class="string">'玩家获胜!'</span>)</span><br><span class="line">        money += debt</span><br><span class="line">    <span class="keyword">elif</span> first == <span class="number">2</span> <span class="keyword">or</span> first == <span class="number">3</span> <span class="keyword">or</span> first == <span class="number">12</span>:</span><br><span class="line">        print(<span class="string">'庄家获胜!'</span>)</span><br><span class="line">        money -= debt</span><br><span class="line">    <span class="keyword">else</span>:</span><br><span class="line">        needs_go_on = <span class="literal">True</span></span><br><span class="line"></span><br><span class="line">    <span class="keyword">while</span> needs_go_on:</span><br><span class="line">        current = randint(<span class="number">1</span>, <span class="number">6</span>)+randint(<span class="number">1</span>, <span class="number">6</span>)</span><br><span class="line">        print(<span class="string">'玩家摇出%d点'</span> % current)</span><br><span class="line">        <span class="keyword">if</span> current == <span class="number">7</span>:</span><br><span class="line">            print(<span class="string">'庄家胜'</span>)</span><br><span class="line">            money -= debt</span><br><span class="line">            needs_go_on = <span class="literal">False</span></span><br><span class="line">        <span class="keyword">elif</span> current == first:</span><br><span class="line">            print(<span class="string">'玩家胜'</span>)</span><br><span class="line">            money += debt</span><br><span class="line">            needs_go_on = <span class="literal">False</span></span><br><span class="line"></span><br><span class="line">print(<span class="string">'你破产了, 游戏结束!'</span>)</span><br></pre></td></tr></table></figure>


      
    </div>
    <footer class="article-footer">
      <a data-url="http://zhaobin.statusplus.top/2019/09/04/craps/" data-id="ck062k48u0000q0xume984aac" class="article-share-link">Share</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Python/">Python</a></li></ul>

    </footer>
  </div>
  
    
<nav id="article-nav">
  
    <a href="/2019/09/04/two-sum/" id="article-nav-newer" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Newer</strong>
      <div class="article-nav-title">
        
          LeetCode - 两数之和
        
      </div>
    </a>
  
  
    <a href="/2019/09/04/ppdi/" id="article-nav-older" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Older</strong>
      <div class="article-nav-title">水仙花数</div>
    </a>
  
</nav>

  
</article>

</section>
        
          <aside id="sidebar">
  
    

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">标签</h3>
    <div class="widget">
      <ul class="tag-list"><li class="tag-list-item"><a class="tag-list-link" href="/tags/JavaScript/">JavaScript</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Python/">Python</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">标签云</h3>
    <div class="widget tagcloud">
      <a href="/tags/JavaScript/" style="font-size: 10px;">JavaScript</a> <a href="/tags/Python/" style="font-size: 20px;">Python</a>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">归档</h3>
    <div class="widget">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/09/">九月 2019</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">最新文章</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="/2019/09/05/fibonacci/">斐波那契数列</a>
          </li>
        
          <li>
            <a href="/2019/09/04/two-sum/">LeetCode - 两数之和</a>
          </li>
        
          <li>
            <a href="/2019/09/04/craps/">赌博游戏</a>
          </li>
        
          <li>
            <a href="/2019/09/04/ppdi/">水仙花数</a>
          </li>
        
      </ul>
    </div>
  </div>

  
</aside>
        
      </div>
      <footer id="footer">
  
  <div class="outer">
    <div id="footer-info" class="inner">
      &copy; 2019 zhaobin<br>
      Powered by <a href="http://hexo.io/" target="_blank">Hexo</a>
    </div>
  </div>
</footer>
    </div>
    <nav id="mobile-nav">
  
    <a href="/" class="mobile-nav-link">Home</a>
  
    <a href="/archives" class="mobile-nav-link">Archives</a>
  
</nav>
    

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>


  <link rel="stylesheet" href="/fancybox/jquery.fancybox.css">
  <script src="/fancybox/jquery.fancybox.pack.js"></script>


<script src="/js/script.js"></script>



  </div>
</body>
</html>